<?php 
/*
* nutdb is a simple way to store data,
* simple method to select/insert/update
* data.
*/
// class nutdb ,which get data from file.
class NutDB
{

	//version
  	const VERSION = '0.1.0';
	
	// DB file .
	protected $FileDB;
	
	// Array to temporality store the data .
	protected $arrayData;
	
	protected $drawer;
	
	protected $box;
	
	protected $colum;
	
	protected $row;
	
	//
	//
	public function __construct($config)
	{
		$this->setDrawer($config['drawer']);
	 	$this->setBox($config['box']);
		$this->setColum($config['colum']);
		$this->setRow($config['row']);
		
	}
	
	//
	//	
	public function setDrawer($drawer)
	{
		$this->drawer = $drawer;
		return $this;	
	}
	
    //
	//
	public function setBox($box)
	{
		$this->box = $box;
		return $this;	
	}
	
	//
	//
	public function setColum($colum)
	{
		$this->colum = $colum;
		return $this;	
	}
	
	//
	//
	public function setRow($row)
	{
		$this->row = $row;
		return $this;	
	}
	
	// public function select($drawer,$box,$colum,$row)
	// {
		
		// file_get_contents($drawer);
				
	// }

	//
	// Check if it is an nutdb data file .
	// Check whether data file is usable or not.
	public function _nutMatch($str)
	{
		// preg_match(START_DRAWER,$str,$matches);
		// preg_match(START_BOX,$str,$matches);
		// preg_match(START_RECORD,$str,$matches);
		// preg_match(END_DRAWER,$str,$matches);
		// preg_match(END_BOX,$str,$matches);
		// preg_match(END_RECORD,$str,$matches);
		// preg_match(SEPARATION,$str,$matches);
		
		//
		//
		$charAt = 0;
		
		// echo '<br>'.strlen($str);
		while($charAt < strlen($str)){
			// echo '<br>'.$charAt.'=>'.$str[$charAt];
			
			preg_match(START_DRAWER,$str[$charAt],$matches);
				
					
			$charAt++;
		}
		
				
	
	}

	//
	// Get data from file into an array.
	// Return an array of data.
	public function select()
	{
		$str = file_get_contents($this->drawer);
		// var_dump($str);
		// $this -> _nutMatch($str);
		
		for(){
		
		}
						
	}

	//
	//
	public function insert()
	{
	
	}
	
	//
	//
	public function update()
	{
	
	}
}


?>